import config from '@/config/cityConfig'
import { get } from '@/utils/request'

// 模型层,数据处理
// 获取影院列表数据
export const getCityApi = async () => {
  let ret = await get(config.city)
  // 返回的数据对象
  let result = {}
  // 得到当前的根据字母排列的集合
  for (let i = 65; i <= 90; i++) {
    result[String.fromCharCode(i)] = []
  }
  Object.keys(result).forEach(key => {
    result[key] = ret.data.cities.filter(item => new RegExp('^' + key, 'i').test(item.pinyin))
    if (result[key].length == 0) delete result[key]
  })
  return result
}

